-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[VPA] Add subresource status for vpa with e2e fix #5766
Conversation
This PR may require API review. If so, when the changes are ready, complete the pre-review checklist and request an API review. Status of requested reviews is tracked in the API Review project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should mention the breaking change in the release notes.
Also a couple comments asking for some small code changes.
Add status field in subresource on crd yaml and add new ClusterRole system:vpa-actor to patch /status subresource. The `metadata.generation` only increase on vpa spec update. Fix e2e test for patch and create vpa
9a0521a
to
1384c8b
Compare
// apiserver ignore status in vpa create, so need to update status | ||
if !isStatusEmpty(&vpa.Status) { | ||
if vpa.Status.Recommendation != nil { | ||
PatchVpaRecommendation(f, vpa, vpa.Status.Recommendation) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment is needed in InstallVPA that create vpa with status need individual update status, so isStatusEmpty needs to be preserved, and the code may appear a bit redundant
A comment is needed leave in InstallVPA that create vpa with status need individual update status, so isStatusEmpty needs to be preserved, and the code may appear a bit redundant
A note in release notes is done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
I left one small comment to make code a bit cleaner.
I think this is good to merge but:
- Our release is overdue, I want to wait with merging until we release to avoid further delays
- I want to check if we're good on the API change (this is a breaking API change)
So
/hold
@@ -372,6 +372,23 @@ func InstallVPA(f *framework.Framework, vpa *vpa_types.VerticalPodAutoscaler) { | |||
vpaClientSet := getVpaClientSet(f) | |||
_, err := vpaClientSet.AutoscalingV1().VerticalPodAutoscalers(f.Namespace.Name).Create(context.TODO(), vpa, metav1.CreateOptions{}) | |||
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unexpected error creating VPA") | |||
// apiserver ignore status in vpa create, so need to update status | |||
if !isStatusEmpty(&vpa.Status) { | |||
if vpa.Status.Recommendation != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd write this as one condition:
if !isStatusEmpty(&vpa.Status) && vpa.Status.Recommendation != nil {
Release is tracked in #5851 |
bytes, err := json.Marshal(patches) | ||
if err != nil { | ||
klog.Errorf("Cannot marshal VPA status patches %+v. Reason: %+v", patches, err) | ||
return | ||
} | ||
|
||
return vpaClient.Patch(context.TODO(), vpaName, types.JSONPatchType, bytes, meta.PatchOptions{}) | ||
return vpaClient.Patch(context.TODO(), vpaName, types.JSONPatchType, bytes, meta.PatchOptions{}, "status") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a unit test we can add to cover this change?
Maybe using the fake client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is already have test case on TestUpdateVpaIfNeeded
autoscaler/vertical-pod-autoscaler/pkg/utils/vpa/api_test.go
Lines 93 to 101 in 1384c8b
for _, tc := range testCases { | |
t.Run(tc.caseName, func(t *testing.T) { | |
fakeClient := vpa_fake.NewSimpleClientset(&vpa_types.VerticalPodAutoscalerList{Items: []vpa_types.VerticalPodAutoscaler{*tc.observedVpa}}) | |
_, err := UpdateVpaStatusIfNeeded(fakeClient.AutoscalingV1().VerticalPodAutoscalers(tc.updatedVpa.Namespace), | |
tc.updatedVpa.Name, &tc.updatedVpa.Status, &tc.observedVpa.Status) | |
assert.NoError(t, err, "Unexpected error occurred.") | |
actions := fakeClient.Actions() | |
if tc.expectedUpdate { | |
assert.Equal(t, 1, len(actions), "Unexpected number of actions") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, makes sense.
/lgtm |
The release is published, are we good to unhold @jbartosik ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
/hold cancel
Yup, I think we can merge this
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jbartosik, wu0407 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
please help me point what is the problem, because i has not enviroment to test. I get a acount on kubernetes slack. @kwiesmueller |
Add status field in subresource on crd yaml and add new ClusterRole system:vpa-actor to patch /status subresource.
The
metadata.generation
only increase on vpa spec update.Fix e2e test for patch and create vpa
What type of PR is this?
/kind bug
/kind failing-test
/kind api-change
What this PR does / why we need it:
Current vpa crd has empty subresource field, that leads to metadata.generation increase on vpa status update.
The controller-runtime has GenerationChangedPredicate to filter out update status event for cr, but it not work for vpa.
This PR add status field in subresource on crd yaml and add new ClusterRole system:vpa-actor to patch /status subresource.
The metadata.generation only increase on vpa spec update.
Which issue(s) this PR fixes:
Fixes #5675
Special notes for your reviewer:
Previous pull request is #5680 and be revert #5738, because of e2e test failed #5727.
This PR fixes e2e test failure.
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: